package com.ruike.alisurface.ui.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.ruike.alisurface.R;

import java.util.List;

public class QrCodeAdapter extends BaseAdapter {

    private Context mContext;
    List<String> codes;

    public QrCodeAdapter(Context context, List<String> codes) {
        this.mContext = context;
        this.codes = codes;
    }


    @Override
    public int getCount() {
        return codes.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_gridview_item, parent, false);
            viewHolder = new ViewHolder();
            viewHolder.itemText =  convertView.findViewById(R.id.item_codes_tv);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        if (codes.get(position).equals("删除") || codes.get(position).equals("确认")) {
            viewHolder.itemText.setTextSize(30f);
        }
        viewHolder.itemText.setText(String.format("%s", codes.get(position)));
        return convertView;
    }


    class ViewHolder {
        TextView itemText;
    }

}